package com.czy.owner.api;

import com.czy.owner.db.UserHelper;
import com.czy.owner.global.Constants;
import com.czy.owner.net.api.BaseApi;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

import java.util.HashMap;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by wangyang on 2017/5/11 0011.
 */

public class OwnCouponsListApi extends BaseApi {
    private String session;
    private String status;
    private String size;
    private String page;
//    private String storeId;
    private String closeMall;

    public OwnCouponsListApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity, String page, String status) {
        super(listener, rxAppCompatActivity);
        setShowProgress(false);
        setCache(true);
        setMothed(UserHelper.getInstance().getUserAccount() + status + Constants.OWN_COUPONSLIST);//相当于缓存保存的Key
        setCookieNetWorkTime(0);//有网缓存0s,在0s内点击无效
        setCookieNoNetWorkTime(24 * 60 * 60 * 7);//无网缓存7天
        setmCachePage(page);//默认缓存第一页


    }

    public String getSession() {
        return session;
    }

    public void setSession(String session) {
        this.session = session;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

//    public String getStoreId() {
//        return storeId;
//    }
//
//    public void setStoreId(String storeId) {
//        this.storeId = storeId;
//    }

    public String getCloseMall() {
        return closeMall;
    }

    public void setCloseMall(String closeMall) {
        this.closeMall = closeMall;
    }

    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        HashMap<String, Object> map = new HashMap<>();
        map.put("session", getSession());
        map.put("status", getStatus());
        map.put("page", getPage());
        map.put("size", getSize());
//        map.put("storeId",getStoreId());
        map.put("closeMall",getCloseMall());
        return service.getOwnCouponListApi(map);
    }
}
